package cn.wolfcode.wolf2w.controller;

import cn.wolfcode.wolf2w.domain.*;
import cn.wolfcode.wolf2w.service.*;
import cn.wolfcode.wolf2w.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("destinations")
public class DestinationController {

    @Autowired
    private IRegionService regionService;

    @Autowired
    private IDestinationService destinationService;

    @Autowired
    private IStrategyCatalogService strategyCatalogService;

    @Autowired
    private IStrategyService strategyService;

    @Autowired
    private ITravelService travelService;

    /**
     * 查询热门目的地页面数据并排序
     *
     * @return:热门目的地
     */
    @GetMapping("/hotRegion")
    public Object hotRegion() {
        List<Region> list = regionService.queryhotRegion();
        return JsonResult.success(list);
    }


    /**
     * 查询父目的地下的子目的地
     *
     * @param regionId:区域id
     * @return:目的地
     */
    @GetMapping("/search")
    public Object search(String regionId) {
        List<Destination> Destlist = destinationService.queryDestByRegionIdforApi(regionId);
        return JsonResult.success(Destlist);
    }


    //目的地明细吐司
    @GetMapping("/toasts")
    public Object toasts(String destId) {
        List toasts = destinationService.queryToasts(destId);
        return JsonResult.success(toasts);
    }


    //目的下所有攻略分类
    @GetMapping("/catalogs")
    public Object catalogs(String destId) {
        List<StrategyCatalog> catalogs = strategyCatalogService.queryCatalogByDestId(destId);
        return JsonResult.success(catalogs);
    }

    //查询攻略点击量最高3篇
    @GetMapping("/strategies/viewnumTop3")
    public Object viewnumTop3(String destId) {
      List<Strategy> strategies = strategyService.QueryTop3ByDestId(destId);
      return JsonResult.success(strategies);
    }

    //查询出游记前三
    @GetMapping("/travels/viewnumTop3")
    public Object travelsviewnumTop3(String destId) {
        List<Travel> travelList = travelService.viewnumTop3(destId);
        return JsonResult.success(travelList);
    }


    //查询出目的地在游记显示下拉框
    @GetMapping("/list")
    public Object list() {
        List<Destination> destinationList = destinationService.list();
        return JsonResult.success(destinationList);
    }
}

